#!/bin/bash

# 脚本：下载 flutter_flutter 仓库
# 如果 flutter_flutter 目录不存在，则通过 git clone 下载

# 获取脚本所在目录的绝对路径
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FLUTTER_DIR="${SCRIPT_DIR}/flutter_flutter"
GIT_URL="https://gitcode.com/openharmony-tpc/flutter_flutter.git"

echo "检查 flutter_flutter 目录..."

# 检查 flutter_flutter 目录是否存在
if [ -d "$FLUTTER_DIR" ]; then
    echo "flutter_flutter 目录已存在，跳过下载步骤。"
else
    echo "flutter_flutter 目录不存在，开始克隆..."
    
    # 检查 git 是否安装
    if ! command -v git > /dev/null; then
        echo "错误：git 未安装，请先安装 git。"
        exit 1
    fi
    
    # 克隆仓库
    git clone "$GIT_URL" "$FLUTTER_DIR"
    
    # 检查克隆是否成功
    if [ $? -ne 0 ]; then
        echo "错误：git clone 失败。"
        exit 1
    fi
    
    echo "flutter_flutter 仓库克隆完成！"
fi

echo "脚本执行完毕。"